Amonel

Welcome Portfolio Projects Contact
↑ Go Back ↑

LXD port forwards

LXD port forwards

These commands can be used to configure a port forward from the host to an LXD container

lxc config device show <containername>

Add network device for static IPv4

lxc config device add <containername> eth0 nic network=lxdbr0

Configure the network device with static IPv4 -> this overrides the DHCP default automatically

lxc config device set <containername> eth0 ipv4.address=10.XXX.XXX.XXX

Add port forward device (samples for TCP and UDP)

IPv4: lxc config device add <containername> <containername>-tcp proxy nat=true listen=tcp:[XXX:XXX:XXX]:443 connect=tcp:[XXX:XXX:XXX]:443 lxc config device add <containername> <containername>-udp proxy nat=true listen=udp:[XXX:XXX:XXX]:443 connect=udp:[XXX:XXX:XXX]:443

IPv6: Use nginx reverse proxy stream module instead, since it's much easier

Edit a port forward device

lxc config device set <containername> <containername>-tcp listen tcp:192.168.XXX.XXX:8443

Show the devices:

lxc config device show <containername>